<?php

namespace app\admin\validate;

use think\Validate;

class PayConfig extends Validate
{
    //字段规则
    protected $rule = [
        'title' => 'require|unique:pay_config',
        'nickname' => 'require|unique:pay_config',
        'configjson' => 'require',
        'switch' => 'require',
        'is_default' => 'require',
    ];

    //验证器提示信息
    protected $message = [
        'title.require' => '支付名称不能为空',
        'title.unique' => '支付名称已经存在',
        'nickname.require' => '支付标识不能为空',
        'nickname.unique' => '支付标识已经存在',
        'configjson.require' => '配置信息不能为空',
        'switch.require' => '开关不能为空',
        'is_default.require' => '默认不能为空',
    ];

    //使用场景
    protected $scene = [
        'add'  =>  ['title','nickname','configjson','switch','is_default'],
        'edit'   => ['title' => 'require','configjson','switch','is_default']
    ];
}